package org.kust.bbs.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.kust.bbs.admin.service.IAdminRoleService;
import org.kust.bbs.common.web.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 管理员角色关联表 前端控制器
 * </p>
 */
@RestController
@RequestMapping("/ams/adminRole")
@Api(tags = "账号角色关联模块")
public class AdminRoleController {
    @Autowired
    private IAdminRoleService adminRoleService;

    /**
     * 账号新增关联角色
     */
    @ApiOperation(value = "重新绑定角色账号关联")
    @PostMapping("/save")
    //@PreAuthorize("hasAuthority('/ams/admin/read')")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "adminId"),
            @ApiImplicitParam(value = "角色id", name = "roleId")
    })
    public JsonResult addAdminRole(Long adminId, Long roleId) {
        adminRoleService.addAdminRoles(adminId, roleId);
        return JsonResult.ok();
    }
}
